package org.visionlibrary.image.geomtric.model;



public class TCircle extends TShape {
	public static final int MINIMAL_SEG_NUM = 3;

	private TCircle(String name) {
		super(name);
	}

	public TCircle(String name, double radius) {
		this(name, radius, 5);
	}

	public TCircle(String name, double radius, int parts) {
		super(name);
		Point2d center = new Point2d(radius, radius);
		Point2d a = new Point2d(radius, 0);
		int numOfSegments = parts;
		if (MINIMAL_SEG_NUM > numOfSegments) {
			numOfSegments = MINIMAL_SEG_NUM;
		}

		for (int i = 0; i < numOfSegments; i++) {
			double angStep = (2 * Math.PI) / numOfSegments;
			Point2d b = Point2d.rotate(a, center, angStep);
			segments.add(new Vector2d(a, b));
			a = b;
		}
	}

	@Override
	public TShape copy(String name) {
		TCircle ccopy = new TCircle(name);
		ccopy.segments = org.visionlibrary.image.geomtric.lines.Lines.copy(segments);
		return ccopy;
	}
}